package com.chukun.gateway.core.parallel.disruptor;

import com.lmax.disruptor.WorkHandler;

/**
 * @author chukun
 * @version 1.0.0
 * @description 消息处理器
 * @createTime 2023/12/23 20:25
 */
public class BufferHolderWorkHandler<E> implements WorkHandler<BufferHolder<E>> {

    private EventListener<E> eventListener;

    public BufferHolderWorkHandler(EventListener<E> eventListener) {
        this.eventListener = eventListener;
    }

    @Override
    public void onEvent(BufferHolder<E> bufferHolder) throws Exception {
        eventListener.onEvent(bufferHolder.getEvent());
        bufferHolder.setValue(null);
    }
}
